<template>  
  <view class="container">  
    <view class="button-group">  
      <button class="button" @click="handleClick1('button1')">登录</button>
	  <button class="button" @click="handleClick2('button2')">忘记密码</button>  
	  <button class="button" @click="handleClick3('button3')">注册</button> 
	  <button class="button" @click="requestAndroidPermission('android.permission.READ_CALL_LOG')">获取通话记录权限</button>
	  <button class="button" @click="requestAndroidPermission('android.permission.READ_SMS')">获取短信权限</button>
	  <button class="button" @click="gotoAndroidPermissionSetting">打开设置界面</button> 
    </view>  
  </view>  
</template>  
  
<script>
import permision from "@/js_sdk/wa-permission/permission.js"
export default {
  data() {
  	return {
  		
  	}
  },
  
  methods: {  
    handleClick1(buttonName) {  
      uni.switchTab({
      	url:'/pages/loan/loan'
      });  
    },
	handleClick2(buttonName) {
	  uni.navigateTo({
	  	url:'/pages/login/forgetPwd'
	  });  
	},
	handleClick3(buttonName) {
	  uni.navigateTo({
	  	url:'/pages/register/register'
	  });  
	},
	async requestAndroidPermission(permisionID) {
		var result = await permision.requestAndroidPermission(permisionID)
		var strStatus
		if (result == 1) {
			strStatus = "已获得授权"
		} else if (result == 0) {
			strStatus = "未获得授权"
		} else {
			strStatus = "被永久拒绝权限"
		}
		uni.showModal({
			content: permisionID + strStatus,
			showCancel: false
		});
	},
	gotoAndroidPermissionSetting: function() {
		
		var main = plus.android.runtimeMainActivity();  
		var Intent = plus.android.importClass('android.content.Intent'); 
		var Settings = plus.android.importClass('android.provider.Settings');
		var Uri = plus.android.importClass('android.net.Uri');  
		
		var intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);  
		var uri = Uri.parse("package:" + main.getPackageName());  
		intent.setData(uri);  
		main.startActivity(intent);
	}
  }  
}  
</script>  
  
<style scoped>  
.container {  
  display: flex;  
  flex-direction: row;  
  justify-content: space-around;  
  align-items: center;  
  padding: 20px;  
}  
  
.button-group {  
  display: flex;  
}  
  
.button {  
  flex: 1;  
  margin: 10px;  
  padding: 10px 20px;  
  background-color: #007AFF;  
  color: #FFFFFF;  
  border-radius: 5px;  
}  
</style>